﻿Imports DTO
Imports System.Data.SqlClient

Public Class CThamSoDAO
    Public Function LoaiDanhSachThamSo() As CThamSoDTO
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_LayGiaTriBangThamSo", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim thamsodto As CThamSoDTO
            Using reader As IDataReader = cm.ExecuteReader(CommandBehavior.CloseConnection)
                reader.Read()
                thamsodto = New CThamSoDTO(reader)
            End Using
            Return thamsodto
        End Using
    End Function

    Public Sub UpdateTuoiLonNhat(ByVal tuoilonnhat As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatTuoiLonNhat", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@tuoilonnhat", tuoilonnhat)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using

    End Sub

    'Me.m_iTuoiNhoNhat = _reader("TuoiNhoNhat")
    Public Sub UpdateTuoiNhoNhat(ByVal tuoinhonhat As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatTuoiNhoNhat", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@tuoinhonhat", tuoinhonhat)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub


    'Me.m_iTienPhatTraTreMoiNgay = _reader("TienPhatTraTreMoiNgay")
    Public Sub UpdateTienPhatTraTreMoiNgay(ByVal tienphattratremoingay As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatTienPhatTraTreMoiNgay", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@tienphattratremoingay", tienphattratremoingay)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    'Me.m_iThoiHanSach = _reader("ThoiHanSach")
    Public Sub UpdateThoiHanSach(ByVal thoihansach As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatThoiHanSach", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@thoihansach", thoihansach)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub


    'Me.m_iThoiHanMuonToiDa = _reader("ThoiHanMuonToiDa")
    Public Sub UpdateThoiHanMuonToiDa(ByVal thoihanmuontoida As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatThoiHanMuonToiDa", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@thoihanmuontoida", thoihanmuontoida)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    Public Function LayThoiHanMuonToiDa() As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspLayThoiHanMuonToiDa", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim n As Integer = cm.ExecuteScalar()
            cn.Close()
            Return n
        End Using
    End Function

    Public Function LayTienPhatTraTre() As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspLayTienPhatTraTre", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim n As Integer = cm.ExecuteScalar()
            cn.Close()
            Return n
        End Using
    End Function


    'Me.m_iSoLyDoThanhLy = _reader("SoLyDoThanhLy")
    Public Sub UpdateSoLyDoThanhLy(ByVal solydothanhly As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLyDoThanhLy", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@solydothanhly", solydothanhly)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub


    'Me.m_iSoLuongTheLoaiSach = _reader("SoLuongTheLoaiSach")
    Public Sub UpdateSoLuongTheLoaiSach(ByVal sotheloaisach As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLuongTheLoaiSach", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@soluongtheloaisach", sotheloaisach)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub


    'Me.m_iSoLuongMuonToiDa = _reader("SoLuongMuonToiDa")
    Public Sub UpdateSoLuongMuonToiDa(ByVal soluongmuontoida As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLuongMuonToiDa", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@soluongmuontoida", soluongmuontoida)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    Public Function LaySoLuongMuonToiDa() As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspLaySoLuongMuonToiDa", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim n As Integer = cm.ExecuteScalar()
            cn.Close()
            Return n
        End Using
    End Function

    'Me.m_iSoLuongChucVu = _reader("SoLuongChucVu")
    Public Sub UpdateSoLuongChucVu(ByVal soluongchucvu As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLuongChucVu", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@soluongchucvu", soluongchucvu)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    'Me.m_iSoLuongBoPhan = _reader("SoLuongBoPhan")
    Public Sub UpdateSoLuongBoPhan(ByVal soluongbophan As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLuongBoPhan", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@soluongbophan", soluongbophan)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    'Me.m_iSoLuongBangCap = _reader("SoLuongBangCap")
    Public Sub UpdateSoLuongBangCap(ByVal soluongbangcap As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLuongBangCap", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@soluongbangcap", soluongbangcap)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    'Me.m_iSoLoaiDocGia = _reader("SoLoaiDocGia")
    Public Sub UpdateSoLoaiDocGia(ByVal soloaidocgia As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatSoLoaiDocGia", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@soloaidocgia", soloaidocgia)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub


    'Me.m_iGiaTriThe = _reader("GiaTriThe")
    Public Sub UpdateGiaTriThe(ByVal giatrithe As Integer)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("usp_CapNhatGiaTriThe", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As New SqlParameter("@giatrithe", giatrithe)
            cm.Parameters.Add(para)
            cm.ExecuteNonQuery()
            cn.Close()
        End Using
    End Sub

    Public Function LayThoiHanThe() As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspLayThoiHanThe", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim n As Integer = cm.ExecuteScalar()
            cn.Close()
            Return n
        End Using
    End Function

End Class
